#include "Track.h"

Track::Track(int w,int l){
	length=l;
	width=w;
}

void Track::draw(int offsetFromDistanceTravelled){

	glPushMatrix();
	//glColor3f(.5,.5,.5);
	for (int i=offsetFromDistanceTravelled; i<50+offsetFromDistanceTravelled; i++)
	{
		//GLfloat blackSpecularMaterial[] = {0.0, 0.0, 0.0};
		//glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR,blackSpecularMaterial);

		glPushMatrix();
		glScalef(width/10,.1,length/50);
		glTranslatef(0,0,-i);

		glPushMatrix();
		glColor3f(1,1,1);
		glScalef(0.33f,1,1);
		if(i%2==1){
			glTranslatef(-1,0,0);		
			glutSolidCube(1);

			glTranslatef(2,0,0);		
			glutSolidCube(1);
		}
		glPopMatrix();
		
		glTranslatef(-5,0,0);
		glColor3f((50-i+offsetFromDistanceTravelled)/40.0-0.5,
			(50-i+offsetFromDistanceTravelled)/40.0-0.5,
			(50-i+offsetFromDistanceTravelled)/40.0-0.5);
		for(int j=0;j<11;j++){

			glutSolidCube(1);
			glTranslatef(1,0,0);
		}
		glPopMatrix();
	}
	glPopMatrix();
}
